
/*
*Released on 28th June 2008.
*Any violations can be reported at paritosh@wikiocean.net
*What is treated as violations can be found at www.wikiocean.net/ppl1-voilations*
******************************************************************************
* The contents of this file are subject to POOL Public License 1.0 and later.
* POOL Public License is based on Affero GPL v3 and additional conditions.
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the Affero GPL v3 License at http://www.gnu.org/licenses/agpl.html
* You may obtain a copy of the POOL Public License 1.0 or later at www.wikiocean.net/license/ppl.html
* Software distributed under POOL Public License 1.0 is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Initial Developer of the Original Code is Paritosh Pungaliya (C) 2008. All Rights Reserved.
******************************************************************************
* Objective of the additional terms (license)
* 1) Is to extend the software freedom to freedom to work.
* 2) To ensure that knowledge is free from monopoly of agencies.
* 3) To avoid a situation where big corporate or investor can buy out free software groups and companies and then start milking the communities built around it.
* (this trend can be seen how the freedom is curtailed in companies that get Venture Capital funding.)
******************************************************************************
*/

package  gui;

import java.io.File;
import java.io.FileWriter;
import java.util.Hashtable;
import java.util.LinkedList;

import org.apache.log4j.Appender;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
/**
 * This class generates html tags and then writes them into a file.
 * 
 */
public class GuiMain 
{
	
	private String path;
	private char ch;
	Logger logger;
	/**
	 * Constructor accepts path of the text file from which HTML
	 * page is to be generated
	 * @param path path of text file name
	 * @param ch Special character
	 */
	public GuiMain(String path, char ch) 
	{
		this.path = path;
		this.ch = ch;
		
		logger = Logger.getLogger(GuiMain.class);
		logger.setLevel(Level.ALL);
		
		PropertyConfigurator.configure("pool.properties");
		//FileAppender fa = new FileAppender(A2, filename);
		
	}
	/**
	 * This method accepts a StringBuffer and writes it to a file
	 * @param sbr StringBuffer containing HTML tags.
	 */
	public void generateFile(StringBuffer sbr)
	{
		try
		{
			File f = new File("d://TextFiles//GeneratedFiles//Result.html");
            if(f.createNewFile())
            {
            	//System.out.println("FILE CREATED");
            	logger.info("FILE CREATED");
            }
            else
            {
            	//System.out.println("FILE NOT CREATED");
            	logger.info("FILE NOT CREATED");
            }

            FileWriter fr = new FileWriter(f);
            fr.write(sbr.toString());
            fr.close();	   
		}
		catch (Exception e) 
		{
			e.printStackTrace();
		}		
	}
	/**
	 * This file generates HTML tags fom the text file.
	 * @return StringBuffer containing HTML tags.
	 */
	public StringBuffer generateHTMLTags()
	{
            Hashtable< Object, LinkedList<Object>> hash;
            /*GenerateHtml gen = new GenerateHtml(Filepath,ch);
            gen.generate("html5");*/

            /*FileObjectsfinder find = new FileObjectsfinder(path);
            hash = find.getobject_Properties();

            FileNameFinder findfile = new FileNameFinder(path);
            String objectname = findfile.find();

            GetReportData get = new GetReportData(objectname,hash,ch);
            
            sbr.append(get.getData());*/
            StringBuffer sbr = new StringBuffer();
            return sbr;
	}
	
	public void setData()
	{
		logger.info("Info");
		logger.warn("Warn");
		logger.debug("Debug");
		logger.fatal("Fatal");
		logger.error("Error");
	}
	public static void main(String[] args) 
   {
	   System.out.println("I'm in main of GUIMain");
	   
	   //String Filepath="c://TextFiles//employeepage.txt";
	   //String Filepath="c://TextFiles//masterpage.txt";
	   String Filepath="d://TextFiles//TestPage.txt";
	   char  ch = '\t'; 
	   GuiMain newgui = new GuiMain(Filepath,ch);
	   /*StringBuffer sbr  =  newgui.generateHTMLTags();
	   System.out.println(sbr.toString());
       newgui.generateFile(sbr);
*/   
	   newgui.setData();
   }
}

